package com.cxy.controller;

import com.cxy.pojo.Result;
import com.cxy.utils.AliOSSUtils1;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Slf4j
@RestController
public class UploadController {
    @Autowired
    private AliOSSUtils1 aliOSSUtils;

    @PostMapping("/upload")
    public Result upload(MultipartFile image) throws Exception {
        log.info("文件上传：文件名：{}",image.getOriginalFilename());
        //调用阿里云工具类上传图片
        String url = aliOSSUtils.upload(image);
        //将url相应给前端
        log.info("文件上传成功，文件url:{}",url);
        return Result.success(url);
    }

}
